#include <iostream>
#include <cmath>
#include "include/Matrix.h"

#define EPSILON 1e-5

using namespace std;

int main(int argc, char **argv)
{
    Matrix A(3,3);
    real data[] = {3, 1, 0,   1, 3, 1,   0, 1, 3 };
    real erroR;
    A.set(data);

    Matrix Q,R;

    do
    {
        real a = A(1,1);
        A.QR_Decomposition(Q,R);
        A = R*Q;
        erroR = fabs(a-A(1,1))/fabs(A(1,1));
        cout << erroR << endl;
    }while(erroR > EPSILON);


    cout << A << endl;

    return 0;
}
